function [theta,distance] = NXTSonarBelt(dir)
reductionRatio = 2;
offset = 6;
power = round(50*dir);
frictionFactor = 1.1;
% COM_CloseNXT all
% h = COM_OpenNXT();
% COM_SetDefaultNXT(h);
OpenUltrasonic(SENSOR_1);
tacholimit = round((11.8/4.4)*360*frictionFactor);
mA = NXTMotor('A', 'Power', power, 'TachoLimit',tacholimit);
mB = NXTMotor('C', 'Power', -power, 'TachoLimit',tacholimit);
Z = mA.ReadFromNXT.TachoCount;
Z2 = 100;
i = 1;
mA.SendToNXT();
mB.SendToNXT();
while (((Z == 0) | (Z2 == 0)) | (Z ~= Z2))
    theta(i) = mA.ReadFromNXT.TachoCount;
    distance(i) = GetUltrasonic(SENSOR_1)+offset;
    Z2 = Z;
    Z = mA.ReadFromNXT.TachoCount;
    i = i+1;
end
mB.WaitFor();
mA.Stop('brake')
mB.Stop('brake')
theta = theta*4.4/(1.1*11.8);
theta = theta*2*pi/360;
% theta = theta*dir;
points = [sin(theta).*distance;cos(theta).*distance];
theta = theta(1:reductionRatio:end);
distance = distance(1:reductionRatio:end);
%plot(points(1,:),points(2,:),'rx')